import React, { PureComponent } from 'react';
import { connect } from 'dva';
import moment from 'moment';
import router from 'umi/router';
import PageHeaderWrapper from '@/components/PageHeaderWrapper';
import avatarMan from '@/assets/avatar_man.png';
import avatarWoman from '@/assets/avatar_woman.png';
import styles from './StaffInfoList.less';
import BaseInfoUpdateForm from './BaseInfoUpdateForm';//更新基本信息表单
import ContactInfoUpdateForm from './ContactInfoUpdateForm';//更新通讯信息表单
import AccountInfoUpdateForm from './AccountInfoUpdateForm';//更新账号信息表单
import EduCreateForm from './EduCreateForm';//新增教育表单
import EduUpdateForm from './EduUpdateForm';//更新教育表单
import WorkCreateForm from './WorkCreateForm';//新增工作表单
import WorkUpdateForm from './WorkUpdateForm';//更新工作表单
import TrainCreateForm from './TrainCreateForm';//新增培训记录表单
import TrainUpdateForm from './TrainUpdateForm';//更新培训记录表单
import CertificateCreateForm from './CertificateCreateForm';//新增证书表单
import CertificateUpdateForm from './CertificateUpdateForm';//更新证书表单
import LinkManCreateForm from './LinkManCreateForm';//新增联系人表单
import LinkManUpdateForm from './LinkManUpdateForm';//更新联系人表单
import {
    Row,
    Col,
    Form, 
    Input,
    Select, 
    Button,
    message,
    Upload,
    Icon,
    Card,
    DatePicker,
    InputNumber,
    Collapse,
    Cascader,
    Modal,
    Spin
} from 'antd';
const { Panel } = Collapse;
const FormItem = Form.Item;
const { confirm } = Modal;
const formItemLayout = {
 	labelCol: { span: 10 },
   	wrapperCol: { span: 14 },
};
/* eslint react/no-multi-comp:0 */
@connect(({ prostaff, loading }) => ({
    prostaff,
    loading: loading.models.prostaff,
}))

@Form.create()
class StaffUpdateForm extends PureComponent {
	
	state = {
	   loading: false,
	   file: null,
	   flag: "1",
	   requestModelName:"prostaff",
	   editBaseInfo: false,
	   editAccountInfo: false,
	   editContactInfo: false,
	   
	   modalVisibleByEdu: false,
	   modalVisibleByWork: false,
	   modalVisibleByLinkMan: false,
	   modalVisibleByTrain: false,
       modalVisibleByCertificate: false,
       eduCurrentIndex:"",
       workCurrentIndex:"",
       trainCurrentIndex: "",
       certificateCurrentIndex: "",
       linkManCurrentIndex: "",
       loadingBaseInfo: false,
       loadingContactInfo: false,
       loadingAccountInfo: false,
       loadingEducation: false,
       loadingWork: false,
       loadingTrain: false,
       loadingCertificate: false
	};
	
	componentDidMount () {
  		const { dispatch } = this.props;
  		const punid = this.props.location.query.id;
  		dispatch({
	    	type: 'prostaff/get_all_city',
	    	payload: {
	    		dictid:"AB"
	    	}
	    });
		dispatch({
	    	type: 'prostaff/get_all_staff_info',
	    	payload: {
	    		punid: punid
	    	}
	   });
	    dispatch({
			type: 'prostaff/get_all_post_for_user',
		});
	}
	
	//编辑基本信息
	genExtraBaseInfo = () => (
		<div 
			style={{color: '#1890FF'}}
			onClick={this.handleBaseInfo}>
			<Icon
		    type="edit"
		  	/>
		  	编辑
		</div>
	);
	
	handleBaseInfo = (event) => {
		event.stopPropagation();
		const { form } = this.props;
		form.resetFields();
		this.setState({
			editBaseInfo: true,
			editContactInfo: false,
			editAccountInfo: false,
			eduCurrentIndex: ""
		})
	}
	
	
	//编辑通讯信息
	genExtraContactInfo = () => (
		<div 
			style={{color: '#1890FF'}}
			onClick={this.handleContactInfo}>
			<Icon
		    type="edit"
		  	/>
		  	编辑
		</div>
	);
	
	handleContactInfo = (event) => {
		event.stopPropagation();
		const { form } = this.props;
		form.resetFields();
		this.setState({
			editContactInfo: true,
			editBaseInfo: false,
			editAccountInfo: false,
			eduCurrentIndex: ""
		})
	}
	
	//编辑账号信息
	genExtraAccountInfo = () => (
		<div 
			style={{color: '#1890FF'}}
			onClick={this.handleAccountInfo}>
			<Icon
		    type="edit"
		  	/>
		  	编辑
		</div>
	);
	
	handleAccountInfo = (event) => {
		event.stopPropagation();
		const { form } = this.props;
		form.resetFields();
		this.setState({
			editAccountInfo: true,
			editContactInfo: false,
			editBaseInfo: false,
			eduCurrentIndex: ""
		})
	}
				
				
	beforeUpload = file => {
		
		this.setState({
	       file:file,
		});

		if(window.FileReader) {
	      const reader = new FileReader();
	      
	      reader.readAsDataURL(file);
	      
			  reader.addEventListener('load', () => {
			  	
			  	this.setState({
		          imageUrl:reader.result,
		          loading: false,
		      })

			  });
		}

	  const isJpgOrPng = file.type === 'image/jpeg' || file.type === 'image/png';
	  if (!isJpgOrPng) {
	    message.error('You can only upload JPG/PNG file!');
	  }
	  const isLt2M = file.size / 1024 / 1024 < 2;
	  if (!isLt2M) {
	    message.error('Image must smaller than 2MB!');
	  }
	  return isJpgOrPng && isLt2M;
	}
		
	handleChange = (value,e) => {
		const { dispatch } = this.props;
		this.setState({
			flag: value
		})
	};
	
	//更新基本信息
  	handleSubmitBaseInfo = (formVals) => {
	    event.preventDefault();
	    const { dispatch } = this.props;
	    this.setState({
			loadingBaseInfo: true
		})
	    const bodymap = {
        	id: formVals.id,
			pname: formVals.pname,
			en_pname: formVals.en_pname,
			phone: formVals.phone,
			gender: formVals.gender,
			country: formVals.country,
			idcard: formVals.idcard,
			passport_number: formVals.passport_number,
			date_of_birth: formVals.date_of_birth,
			birthday: formVals.birthday,
			age: formVals.age,
			place_of_origin: formVals.place_of_origin,
			zdiac: formVals.zdiac,
			constellation: formVals.constellation,
			nation: formVals.nation,
			marital_status: formVals.marital_status,
			blood_type: formVals.blood_type,
			place_of_domicile: formVals.place_of_domicile,
			political_outlook: formVals.political_outlook,
			join_party_time: formVals.join_party_time,
			archiving_agency: formVals.archiving_agency,
			chrildren_status: formVals.chrildren_status,
			chrildren_commercial_insurance: formVals.chrildren_commercial_insurance,
			illegal_activities: formVals.illegal_activities,
			major_medical_history: formVals.major_medical_history,
			first_education: formVals.first_education,
			dept_id: formVals.dept_id,
			dept: formVals.dept,
			post_id: formVals.post_id,
			post_name: formVals.post_name
       	};
       	const formData = new FormData();
        formData.append('uploadfile', formVals.file);
		formData.append('bodymap', JSON.stringify(bodymap));
		dispatch({
            type: 'prostaff/update_for_staff_baseinfo',
            payload: {
            	formdata: formData,
            	id: formVals.id
          	},
          	callback:(res) => {
          		if(res.success) {
          			message.success('更新成功！');
          			this.setState({
						editBaseInfo: false,
						loadingBaseInfo: false
					})
          		}
          	}
      	});
	}
  	//取消更新基本信息
  	cancelEditBaseInfo = () => {
		this.setState({
			editBaseInfo: false
		})
	}
  	
  	//更新通讯信息
  	handleSubmitContactInfo = (formVals) => {
	    event.preventDefault();
	    const { dispatch } = this.props;
	   	this.setState({
			loadingContactInfo: true
		})
		dispatch({
            type: 'prostaff/update_for_staff_contactinfo',
            payload: {
            	id: formVals.id,
            	punid: formVals.punid,
				qq: formVals.qq,
				wx: formVals.wx,
				email: formVals.email,
				phone: formVals.phone,
				postal_address: formVals.postal_address,
				address: formVals.address,
				residence_permit_city: formVals.residence_permit_city,
				residence_permit_start_time: formVals.residence_permit_start_time,
				residence_permit_end_time: formVals.residence_permit_end_time,
				emergency_contact_name: formVals.emergency_contact_name,
				emergency_contact_phone: formVals.emergency_contact_phone
          	},
          	callback:(res) => {
          		if(res.success) {
          			message.success('更新成功！');
          			this.setState({
						editContactInfo: false,
						loadingContactInfo: false
					})
          		}
          	}
      	});
	}
  	
  	//取消更新通讯信息
  	cancelEditContactInfo = () => {
		this.setState({
			editContactInfo: false
		})
	}
  	
  	//更新账号信息
  	handleSubmitAccountInfo = (formVals) => {
	    event.preventDefault();
	    const {  dispatch } = this.props;
	    this.setState({
			loadingAccountInfo: true
		})
	    dispatch({
            type: 'prostaff/update_for_staff_accountinfo',
            payload: {
            	id: formVals.id,
            	punid: formVals.punid,
				social_insurance_computer_number: formVals.social_insurance_computer_number,
				accumulation_fund_number: formVals.accumulation_fund_number,
				bank_card_number: formVals.bank_card_number,
				open_bank: formVals.open_bank 
          	},
          	callback:(res) => {
          		if(res.success) {
          			message.success('更新成功！');
          			this.setState({
						editAccountInfo: false,
						loadingAccountInfo: false
					})
          		}
          	}
      	});
	}
  	
  	//取消更新账号信息
  	cancelEditAccountInfo = () => {
  		const { form } = this.props;
  		form.resetFields();
		this.setState({
			editAccountInfo: false
		})
	}
 	
  	//新增教育信息
  	handleModalVisibleByEdu = flag => {
		this.setState({
			modalVisibleByEdu: !!flag,
		});
	};
  	
  	handleAddByEdu = (fieldsValue) => {
  		event.preventDefault();
	    const { dispatch } = this.props;
  		const punid = this.props.location.query.id;
  		this.setState({
			loadingEducation: true
		})
	    dispatch({
            type: 'prostaff/insert_for_staff_educationinfo',
            payload: {
            	punid: punid,
				graduation_school: fieldsValue.graduation_school,
				major: fieldsValue.major,
				education: fieldsValue.education,
				teaching_methods: fieldsValue.teaching_methods,
				educational_experience_start_time: fieldsValue.educational_experience_start_time,
				educational_experience_end_time: fieldsValue.educational_experience_end_time,
				first_education_type: fieldsValue.first_education_type,
          	},
          	callback:(res) => {
          		if(res.success) {
          			message.success('添加成功！');
          			this.setState({
						loadingEducation: false
					})
          		}
          	}
      	});
      	this.handleModalVisibleByEdu();
  	}
  	
  	
  	//更新教育信息
  	handleEducation = (res) => {
  		const { form } = this.props;
//		form.resetFields();
  		this.setState({
	        eduCurrentIndex:res.id,
	        workCurrentIndex: "",
	        trainCurrentIndex: "",
	        certificateCurrentIndex: "",
	        linkManCurrentIndex: "",
	       	editContactInfo: false,
			editBaseInfo: false,
			editAccountInfo: false
	    });
  	}
  	
  	handleUpdateByEdu = (formVals) => {
		event.preventDefault();
	    const { dispatch } = this.props;
		this.setState({
			loadingEducation: true
		})
	    dispatch({
            type: 'prostaff/update_for_staff_educationinfo',
            payload: {
            	id: formVals.id,
            	punid: formVals.punid,
				graduation_school: formVals.graduation_school,
				major: formVals.major,
				education: formVals.education,
				teaching_methods: formVals.teaching_methods,
				educational_experience_start_time: formVals.educational_experience_start_time,
				educational_experience_end_time: formVals.educational_experience_end_time,
				first_education_type: formVals.first_education_type,
          	},
          	callback:(res) => {
          		if(res.success) {
          			message.success('更新成功！');
					this.setState({
						eduCurrentIndex: "",
						loadingEducation: false
					})
          		}
          	}
      	});
  	}
  	
  	//取消编辑教育信息
  	cancelEducation = () => {
  		const { form } = this.props;
  		form.resetFields();
		this.setState({
			eduCurrentIndex: ""
		})
	}
  	
  	//删除教育信息
	handleDeleteByEdu = record => {
		const { dispatch } = this.props;
		const _this = this;
		confirm({
		    title: '您确定要删除这组教育信息吗?',
		    okText: '确认',
		    cancelText: '取消',
		    onOk() {
		    	_this.setState({
					loadingEducation: true
				})
		        dispatch({
			        type: 'prostaff/delete_for_staff_educationinfo',
			        payload: {
		        		recordid: record.id,
		        		punid: record.punid
			        },
			        callback: (res) => {
			        	if(res.success) {
			    				message.success('删除成功');
			        	}else {
			        		message.success('删除失败');
			        	}
			        	_this.setState({
							loadingEducation: false
						})
			        }
		        });
		    },
		    onCancel() {},
		});

	};
  	
  	//新增工作信息
  	handleModalVisibleByWork = flag => {
		this.setState({
			modalVisibleByWork: !!flag,
		});
	};
  	
  	handleAddByWork = (fieldsValue) => {
  		event.preventDefault();
	    const { dispatch } = this.props;
	    const punid = this.props.location.query.id;
	    this.setState({
			loadingWork: true
		})
	    dispatch({
            type: 'prostaff/insert_for_staff_workinfo',
            payload: {
            	punid: punid,
				corporate_name: fieldsValue.corporate_name,
				position: fieldsValue.position,
				work_experience_start_time: fieldsValue.work_experience_start_time,
				work_experience_end_time: fieldsValue.work_experience_end_time,
				quit_reason: fieldsValue.quit_reason,
				witness: fieldsValue.witness,
				witness_phone: fieldsValue.witness_phone
          	},
          	callback:(res) => {
          		if(res.success) {
          			message.success('添加成功！');
          			this.setState({
						loadingWork: false
					})
          		}
          	}
      	});
      	this.handleModalVisibleByWork();
  	}
  	
  	//更新工作信息
  	handleWork = (res) => {
  		this.setState({
  			workCurrentIndex:res.id,
	        eduCurrentIndex:"",
	        trainCurrentIndex: "",
	        certificateCurrentIndex: "",
	        linkManCurrentIndex: "",
	       	editContactInfo: false,
			editBaseInfo: false,
			editAccountInfo: false
	    });
  	}
  	
  	handleUpdateByWork = (formVals) => {
		event.preventDefault();
	    const {  dispatch } = this.props;
	    this.setState({
			loadingWork: true
		})
	    dispatch({
            type: 'prostaff/update_for_staff_workinfo',
            payload: {
            	id: formVals.id,
            	punid: formVals.punid,
				corporate_name: formVals.corporate_name,
				position: formVals.position,
				work_experience_start_time: formVals.work_experience_start_time,
				work_experience_end_time: formVals.work_experience_end_time,
				quit_reason: formVals.quit_reason,
				witness: formVals.witness,
				witness_phone: formVals.witness_phone,
          	},
          	callback:(res) => {
          		if(res.success) {
          			message.success('更新成功！');
					this.setState({
						workCurrentIndex: "",
						loadingWork: false
					})
          		}
          	}
      	});
  	}
  	
  	//取消编辑工作信息
  	cancelWork = () => {
  		const { form } = this.props;
  		form.resetFields();
		this.setState({
			workCurrentIndex: ""
		})
	}
  	
  	//删除工作信息
	handleDeleteByWork = record => {
		const { dispatch } = this.props;
		const _this = this;
		confirm({
		    title: '您确定要删除这组工作信息吗?',
		    okText: '确认',
		    cancelText: '取消',
		    onOk() {
		    	_this.setState({
					loadingWork: true
				})
		        dispatch({
			        type: 'prostaff/delete_for_staff_workinfo',
			        payload: {
		        		recordid: record.id,
		        		punid: record.punid
			        },
			        callback: (res) => {
			        	if(res.success) {
			    				message.success('删除成功');
			        	}else {
			        		message.success('删除失败');
			        	}
			        	_this.setState({
							loadingWork: false
						})
			        }
		        });
		    },
		    onCancel() {},
		});

	};
  	
  	
  	//新增培训记录
  	handleModalVisibleByTrain = flag => {
		this.setState({
			modalVisibleByTrain: !!flag,
		});
	};
  	
  	handleAddByTrain = (fieldsValue) => {
  		event.preventDefault();
	    const {  dispatch } = this.props;
	    const punid = this.props.location.query.id;
	    this.setState({
			loadingTrain: true
		})
	    dispatch({
            type: 'prostaff/insert_for_staff_traininfo',
            payload: {
            	punid: punid,
				training_course: fieldsValue.training_course,
				training_start_time: fieldsValue.training_start_time,
				training_end_time: fieldsValue.training_end_time,
				training_duration: fieldsValue.training_duration,
				training_mechanism_name: fieldsValue.training_mechanism_name,
				examination_results: fieldsValue.examination_results,
				training_address: fieldsValue.training_address,
				training_type: fieldsValue.training_type
          	},
          	callback:(res) => {
          		if(res.success) {
          			message.success('添加成功！');
          			this.setState({
						loadingTrain: false
					})
          		}
          	}
      	});
      	this.handleModalVisibleByTrain();
  	}
  	
  	//更新培训记录
  	handleTrain = (res) => {
  		this.setState({
  			trainCurrentIndex:res.id,
	        eduCurrentIndex:"",
	        workCurrentIndex:"",
	        certificateCurrentIndex: "",
	        linkManCurrentIndex: "",
	       	editContactInfo: false,
			editBaseInfo: false,
			editAccountInfo: false
	    });
  	}
  	
  	handleUpdateByTrain = (formVals) => {
		event.preventDefault();
	    const {  dispatch } = this.props;
	   	this.setState({
			loadingTrain: true
		})
	    dispatch({
            type: 'prostaff/update_for_staff_traininfo',
            payload: {
            	id: formVals.id,
            	punid: formVals.punid,
				training_course: formVals.training_course,
				training_start_time: formVals.training_start_time,
				training_end_time: formVals.training_end_time,
				training_duration: formVals.training_duration,
				training_mechanism_name: formVals.training_mechanism_name,
				examination_results: formVals.examination_results,
				training_address: formVals.training_address,
				training_type: formVals.training_type,
          	},
          	callback:(res) => {
          		if(res.success) {
          			message.success('更新成功！');
					this.setState({
						trainCurrentIndex: "",
						loadingTrain: false
					})
          		}
          	}
      	});
  	}
  	
  	//取消编辑培训记录
  	cancelTrain = () => {
  		const { form } = this.props;
  		form.resetFields();
		this.setState({
			trainCurrentIndex: ""
		})
	}
  	
  	//删除培训记录
	handleDeleteByTrain = record => {
		const { dispatch } = this.props;
		const _this = this;
		confirm({
		    title: '您确定要删除这组培训记录吗?',
		    okText: '确认',
		    cancelText: '取消',
		    onOk() {
		    	_this.setState({
					loadingTrain: true
				})
		        dispatch({
			        type: 'prostaff/delete_for_staff_traininfo',
			        payload: {
		        		recordid: record.id,
		        		punid: record.punid
			        },
			        callback: (res) => {
			        	if(res.success) {
			    				message.success('删除成功');
			        	}else {
			        		message.success('删除失败');
			        	}
			        	_this.setState({
							loadingTrain: false
						})
			        }
		        });
		    },
		    onCancel() {},
		});

	};
  	
  	//新增证书
  	handleModalVisibleByCertificate = flag => {
		this.setState({
			modalVisibleByCertificate: !!flag,
		});
	};
  	
  	handleAddByCertificate = (fieldsValue) => {
  		event.preventDefault();
	    const { dispatch } = this.props;
	    const punid = this.props.location.query.id;
	    this.setState({
			loadingCertificate: true
		})
	    dispatch({
            type: 'prostaff/insert_for_staff_certificateinfo',
            payload: {
            	punid: punid,
				certificate_name: fieldsValue.certificate_name,
				certificate_number: fieldsValue.certificate_number,
				certificate_start_time: fieldsValue.certificate_start_time,
				certificate_end_time: fieldsValue.certificate_end_time,
				certificate_remarks: fieldsValue.certificate_remarks,
          	},
          	callback:(res) => {
          		if(res.success) {
          			message.success('添加成功！');
          			this.setState({
						loadingCertificate: false
					})
          		}
          	}
      	});
      	this.handleModalVisibleByCertificate();
  	}
  	
  	//更新证书
  	handleCertificate = (res) => {
  		this.setState({
  			certificateCurrentIndex:res.id,
  			trainCurrentIndex: "",
	        eduCurrentIndex:"",
	        workCurrentIndex:"",
	        linkManCurrentIndex: "",
	       	editContactInfo: false,
			editBaseInfo: false,
			editAccountInfo: false
	    });
  	}
  	
  	handleUpdateByCertificate = (formVals) => {
		event.preventDefault();
	    const {  dispatch } = this.props;
	   	this.setState({
			loadingCertificate: true
		})
	    dispatch({
            type: 'prostaff/update_for_staff_certificateinfo',
            payload: {
            	id: formVals.id,
            	punid: formVals.punid,
				certificate_name: formVals.certificate_name,
				certificate_number: formVals.certificate_number,
				certificate_start_time: formVals.certificate_start_time,
				certificate_end_time: formVals.certificate_end_time,
				certificate_remarks: formVals.certificate_remarks,
          	},
          	callback:(res) => {
          		if(res.success) {
          			message.success('更新成功！');
					this.setState({
						certificateCurrentIndex: "",
						loadingCertificate: false
					})
          		}
          	}
      	});
  	}
  	
  	//取消编辑证书
  	cancelCertificate = () => {
  		const { form } = this.props;
  		form.resetFields();
		this.setState({
			certificateCurrentIndex: ""
		})
	}
  	
  	//删除证书
	handleDeleteByCertificate = record => {
		const { dispatch } = this.props;
		const _this = this;
		confirm({
		    title: '您确定要删除这组证书吗?',
		    okText: '确认',
		    cancelText: '取消',
		    onOk() {
		    	_this.setState({
					loadingCertificate: true
				})
		        dispatch({
			        type: 'prostaff/delete_for_staff_certificateinfo',
			        payload: {
		        		recordid: record.id,
		        		punid: record.punid
			        },
			        callback: (res) => {
			        	if(res.success) {
			    				message.success('删除成功');
			        	}else {
			        		message.success('删除失败');
			        	}
			        	_this.setState({
							loadingCertificate: false
						})
			        }
		        });
		    },
		    onCancel() {},
		});

	};
  	
  	//新增联系人
  	handleModalVisibleByLinkMan = flag => {
		this.setState({
			modalVisibleByLinkMan: !!flag,
		});
	};
  	
  	handleAddByLinkMan = () => {
  		
  	}
	
	//更新联系人
  	handleLinkMan = (res) => {
  		this.setState({
  			linkManCurrentIndex:res.id,
  			workCurrentIndex: "",
	        eduCurrentIndex: "",
	        trainCurrentIndex: "",
	        certificateCurrentIndex: "",
	       	editContactInfo: false,
			editBaseInfo: false,
			editAccountInfo: false
	    });
  	}
  	
  	handleUpdateByLinkMan = () => {

  	}
  	
  	//取消编辑联系人
  	cancelLinkMan = () => {
  		const { form } = this.props;
  		form.resetFields();
		this.setState({
			linkManCurrentIndex: ""
		})
	}
  	
  	//删除联系人
	handleDeleteByLinkMan = record => {
		const { dispatch } = this.props;
		confirm({
		    title: '您确定要删除这个联系人吗?',
		    okText: '确认',
		    cancelText: '取消',
		    onOk() {
		        
		    },
		    onCancel() {},
		});

	};

  	render () {
  

    const { getFieldDecorator } = this.props.form
	const uploadButton = (
      <div style={{marginTop: '20px'}}>
        <Icon type={this.state.loading ? 'loading' : 'plus'} />
        <div className="ant-upload-text">上传头像</div>
      </div>
    );

    const { 
    	imageUrl,
    	flag,
    	editBaseInfo,
    	editContactInfo,
    	editAccountInfo,
    	modalVisibleByEdu,
    	modalVisibleByWork,
    	modalVisibleByTrain,
    	modalVisibleByCertificate,
    	modalVisibleByLinkMan,
    	eduCurrentIndex,
    	workCurrentIndex,
    	trainCurrentIndex,
    	certificateCurrentIndex,
    	linkManCurrentIndex,
    	loadingBaseInfo,
       	loadingContactInfo,
       	loadingAccountInfo,
       	loadingEducation,
       	loadingWork,
       	loadingTrain,
       	loadingCertificate,
       	requestModelName
    } = this.state;
    
	const {
		prostaff: {
			staffInfo,
			cascaderList,
			selectDeptTree,
			postForUser
		},
		loading,
		dispatch
	} = this.props;
	const { 
		map:{
			person_information,
			person_communication_information,
			person_account_information,
			person_educational_experience,
			person_work_experience,
			person_training,
			person_certificate
		},
	} = staffInfo;
	//更新基本信息
	const parentUpdateByBaseInfo = {
		dispatch: this.props.dispatch,
		cascaderList,
		selectDeptTree,
		postForUser,
		requestModelName,
		handleSubmitBaseInfo: this.handleSubmitBaseInfo,
		cancelEditBaseInfo: this.cancelEditBaseInfo,
		editBaseInfo
	}
	
	//更新通讯信息
	const parentUpdateByContactInfo = {
		cascaderList,
		handleSubmitContactInfo: this.handleSubmitContactInfo,
		cancelEditContactInfo: this.cancelEditContactInfo,
		editContactInfo
	}
	
	//更新账号信息
	const parentUpdateByAccountInfo = {
		handleSubmitAccountInfo: this.handleSubmitAccountInfo,
		cancelEditAccountInfo: this.cancelEditAccountInfo,
		editAccountInfo
	}
	
	//新增教育经历
	const parentMethodsByEdu = {
		handleAddByEdu: this.handleAddByEdu,
		handleModalVisibleByEdu: this.handleModalVisibleByEdu,
	};
	//更新教育经历
	const parentUpdateByEdu = {
		handleEducation: this.handleEducation,
		handleUpdateByEdu: this.handleUpdateByEdu,
		cancelEducation: this.cancelEducation,
		handleDeleteByEdu: this.handleDeleteByEdu,
		eduCurrentIndex
	};
	
	//新增工作经历
	const parentMethodsByWork = {
		handleAddByWork: this.handleAddByWork,
		handleModalVisibleByWork: this.handleModalVisibleByWork,
	};
	//更新工作经历
	const parentUpdateByWork = {
		handleWork: this.handleWork,
		handleUpdateByWork: this.handleUpdateByWork,
		cancelWork: this.cancelWork,
		handleDeleteByWork: this.handleDeleteByWork,
		workCurrentIndex
	};
	
	//新增培训记录
	const parentMethodsByTrain = {
		handleAddByTrain: this.handleAddByTrain,
		handleModalVisibleByTrain: this.handleModalVisibleByTrain,
	};
	//更新培训记录
	const parentUpdateByTrain = {
		handleTrain: this.handleTrain,
		handleUpdateByTrain: this.handleUpdateByTrain,
		cancelTrain: this.cancelTrain,
		handleDeleteByTrain: this.handleDeleteByTrain,
		trainCurrentIndex
	};
	
	//新增证书
	const parentMethodsByCertificate = {
		handleAddByCertificate: this.handleAddByCertificate,
		handleModalVisibleByCertificate: this.handleModalVisibleByCertificate,
	};
	//更新证书
	const parentUpdateByCertificate = {
		handleCertificate: this.handleCertificate,
		handleUpdateByCertificate: this.handleUpdateByCertificate,
		cancelCertificate: this.cancelCertificate,
		handleDeleteByCertificate: this.handleDeleteByCertificate,
		certificateCurrentIndex
	};
	//新增联系人
	const parentMethodsByLinkMan = {
		handleAddByLinkMan: this.handleAddByLinkMan,
		handleModalVisibleByLinkMan: this.handleModalVisibleByLinkMan,
	};
	//更新联系人
	const parentUpdateByLinkMan = {
		handleLinkMan: this.handleLinkMan,
		handleUpdateByLinkMan: this.handleUpdateByLinkMan,
		cancelLinkMan: this.cancelLinkMan,
		handleDeleteByLinkMan: this.handleDeleteByLinkMan,
		linkManCurrentIndex
	};
	
    return (
    	<PageHeaderWrapper title="编辑员工">
    	<Card bordered={false} style={{width:"80%",margin: '20px auto'}}>
    		<div style={{height: '100px',float: 'left'}}>
    			<img src={ person_information && Object.keys(person_information).length && person_information.photo_sign?person_information.photo_sign:person_information && Object.keys(person_information).length && person_information.gender == "02"?avatarWoman:avatarMan } className={ styles.staffAvatar } alt="搜索标志" />
    		</div>
    		<div style={{height: '100px',float: 'left',marginLeft: '20px'}}>
    			<h2>{person_information && Object.keys(person_information).length? person_information.pname:null}</h2>
    			<div style={{marginTop: '50px'}}>
    				<span style={{marginRight: '10px'}}>
    					手机号<span style={{paddingLeft: '5px',color: '#333'}}>{person_communication_information && Object.keys(person_communication_information).length? person_communication_information.phone:null}</span>
    				</span>
    				<span>
	  					入职日期<span style={{paddingLeft: '5px',color: '#333'}}>{person_information && Object.keys(person_information).length? moment(person_information.entry_time).format('YYYY-MM-DD'):null}</span>
    				</span>
    			</div>
    		</div>
    	</Card>
    <Spin size="large" spinning={loadingBaseInfo}>
    <Collapse
      bordered={false} 
      defaultActiveKey={['1']}
      expandIconPosition="right"
      style={{width:"80%",margin: '20px auto',position: 'relative'}}
    >
    <div className={styles.cardMark}></div>
    <Panel header="基本信息" key="1" extra={this.genExtraBaseInfo()}>
	    <Card bordered={false} style={{ marginTop: '-20px' }}>
	      <div className="demo-container">
	      	{person_information && Object.keys(person_information).length ? (
				<BaseInfoUpdateForm {...parentUpdateByBaseInfo}  values={person_information}/>
			):null}
	      </div>
	    </Card>
    </Panel>
    </Collapse>
    </Spin>
    <Spin size="large" spinning={loadingContactInfo}>
    <Collapse
      bordered={false} 
      defaultActiveKey={['1']}
      expandIconPosition="right"
      style={{width:"80%",margin: '20px auto',position: 'relative'}}
    >
    <div className={styles.cardMark}></div>
    <Panel header="通讯信息" key="1" extra={this.genExtraContactInfo()}>
	    <Card bordered={false} style={{ marginTop: '-20px' }}>
	      <div className="demo-container">
	      		<ContactInfoUpdateForm {...parentUpdateByContactInfo} values={person_communication_information}/>
			  
	      </div>
	    </Card>
    </Panel>
    </Collapse>
    </Spin>
    <Spin size="large" spinning={loadingAccountInfo}>
    <Collapse
      bordered={false} 
      defaultActiveKey={['1']}
      expandIconPosition="right"
      style={{width:"80%",margin: '20px auto',position: 'relative'}}
    >
    <div className={styles.cardMark}></div>
    <Panel header="账号信息" key="1" extra={this.genExtraAccountInfo()}>
	    <Card bordered={false} style={{ marginTop: '-20px' }}>
	      <div className="demo-container">
	      		<AccountInfoUpdateForm {...parentUpdateByAccountInfo} values={person_account_information}/>
	      </div>
	    </Card>
    </Panel>
    </Collapse>
    </Spin>
    <Spin size="large" spinning={loadingEducation}>
    <Collapse
      bordered={false} 
      defaultActiveKey={['1']}
      expandIconPosition="right"
      style={{width:"80%",margin: '20px auto',position: 'relative'}}
    >
    <div className={styles.cardMark}></div>
    <Panel header="教育经历" key="1">
	    <Card bordered={false} style={{ marginTop: '-20px' }}>
	      <EduUpdateForm {...parentUpdateByEdu} values={person_educational_experience}/>
	      <div className={styles.staffcontainer} onClick={() => this.handleModalVisibleByEdu(true)}>
	      	<Icon type="plus-circle" style={{fontSize: '16px',marginRight: '3px'}}/>
	      	<span>添加教育经历</span>
	      </div>
	    </Card>
	    <EduCreateForm {...parentMethodsByEdu} modalVisibleByEdu={modalVisibleByEdu} />
    </Panel>
    </Collapse>
    </Spin>
    <Spin size="large" spinning={loadingWork}>
    <Collapse
      bordered={false} 
      defaultActiveKey={['1']}
      expandIconPosition="right"
      style={{width:"80%",margin: '20px auto',position: 'relative'}}
    >
    <div className={styles.cardMark}></div>
    <Panel header="工作经历" key="1">
	    <Card bordered={false} style={{ marginTop: '-20px' }}>
	      <WorkUpdateForm {...parentUpdateByWork} values={person_work_experience}/>
	      <div className={styles.staffcontainer} onClick={() => this.handleModalVisibleByWork(true)}>
	      	<Icon type="plus-circle" style={{fontSize: '16px',marginRight: '3px'}}/>
	      	<span>添加工作经历</span>
	      </div>
	    </Card>
	    <WorkCreateForm {...parentMethodsByWork} modalVisibleByWork={modalVisibleByWork} />
    </Panel>
    </Collapse>
    </Spin>
    <Spin size="large" spinning={loadingTrain}>
    <Collapse
      bordered={false} 
      defaultActiveKey={['1']}
      expandIconPosition="right"
      style={{width:"80%",margin: '20px auto',position: 'relative'}}
    >
    <div className={styles.cardMark}></div>
    <Panel header="培训记录" key="1">
	    <Card bordered={false} style={{ marginTop: '-20px' }}>
	      <TrainUpdateForm {...parentUpdateByTrain} values={person_training}/>
	      <div className={styles.staffcontainer} onClick={() => this.handleModalVisibleByTrain(true)}>
	      	<Icon type="plus-circle" style={{fontSize: '16px',marginRight: '3px'}}/>
	      	<span>添加培训记录</span>
	      </div>
	    </Card>
	    <TrainCreateForm {...parentMethodsByTrain} modalVisibleByTrain={modalVisibleByTrain} />
    </Panel>
    </Collapse>
    </Spin>
    <Spin size="large" spinning={loadingCertificate}>
    <Collapse
      bordered={false} 
      defaultActiveKey={['1']}
      expandIconPosition="right"
      style={{width:"80%",margin: '20px auto',position: 'relative'}}
    >
    <div className={styles.cardMark}></div>
    <Panel header="证书" key="1">
	    <Card bordered={false} style={{ marginTop: '-20px' }}>
	      <CertificateUpdateForm {...parentUpdateByCertificate} values={person_certificate}/>
	      <div className={styles.staffcontainer} onClick={() => this.handleModalVisibleByCertificate(true)}>
	      	<Icon type="plus-circle" style={{fontSize: '16px',marginRight: '3px'}}/>
	      	<span>添加证书</span>
	      </div>
	    </Card>
	    <CertificateCreateForm {...parentMethodsByCertificate} modalVisibleByCertificate={modalVisibleByCertificate} />
    </Panel>
    </Collapse>
    </Spin>
    {/*<Collapse
      bordered={false} 
      defaultActiveKey={['1']}
      expandIconPosition="right"
      style={{width:"80%",margin: '20px auto',position: 'relative'}}
    >
    <div className={styles.cardMark}></div>
    <Panel header="联系人" key="1">
	    <Card bordered={false} style={{ marginTop: '-20px' }}>
	      <LinkManUpdateForm {...parentUpdateByLinkMan}/>
	      <div className={styles.staffcontainer} onClick={() => this.handleModalVisibleByLinkMan(true)}>
	      	<Icon type="plus-circle" style={{fontSize: '16px',marginRight: '3px'}}/>
	      	<span>添加联系人</span>
	      </div>
	    </Card>
	    <LinkManCreateForm {...parentMethodsByLinkMan} modalVisibleByLinkMan={modalVisibleByLinkMan} />
    </Panel>
    </Collapse>*/}
    </PageHeaderWrapper>
    )

  }
}

export default StaffUpdateForm;